<?php
	require(dirname(__FILE__) . '/includes/init.php');
    //require(dirname(__FILE__) . '/includes/init.php');
$error = null;	
if($_REQUEST['act'] == 'search'){
	if(!empty($_REQUEST['mobile'])){
		$order_list = order_list($_REQUEST['mobile'],0);
	}else if(!empty($_REQUEST['consignee'])){
		$order_list = order_list(0,$_REQUEST['consignee']);
	}
}
/********************************/
else{
	$order_list = order_list();
}
function order_list($key='',$key1=''){
	 /* 查询 */
	 if(empty($key)&&empty($key1)){
		$sql = "SELECT * FROM " .$GLOBALS['ecs']->table('orders')." where money>=500";
	 }else if($key){
        $sql = "SELECT * FROM " .$GLOBALS['ecs']->table('orders')." where mobile='".$key."'";
	 }else{
		$sql = "SELECT * FROM " .$GLOBALS['ecs']->table('orders')." where user like '%".$key1."%'";
	 }
	    $row = $GLOBALS['db']->getAll($sql);
		foreach($row as $index=>$order){
			$sql = "SELECT status FROM ".$GLOBALS['ecs']->table('tracing')."WHERE trace_id = (SELECT max(trace_id) FROM " .$GLOBALS['ecs']->table('tracing')." where order_id='".$order['order_id']."')";
			$status = $GLOBALS['db']->getOne($sql);
			if(!$status){
				$row[$index]['status'] = 0;
			}else{
				$row[$index]['status'] = $status;
			}
		}

		return $row;
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>管理中心 - 大客户订单列表 </title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles/general.css" rel="stylesheet" type="text/css" />
<link href="styles/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
 
<h1>
<span class="action-span1"><a target="_top" href="index.php?act=main">管理中心</a> </span><span id="search_id" class="action-span1"> - 大客户订单列表 </span>
<div style="clear:both"></div>
</h1>

<div class="form-div">
  <form action="vip_orders.php" method="get" name="searchForm">
    <img src="images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
    手机<input name="mobile" type="text" id="mobile" size="15">
    收货人<input name="consignee" type="text" id="consignee" size="15">
	<input type="hidden" name="act" value="search" />
    <input type="submit" value=" 搜索 " class="button" />
  </form>
</div>
 
<!-- 订单列表 -->
<form method="post" action="order.php?act=operate" name="listForm" onsubmit="return check()">
  <div class="list-div" id="listDiv">
 
<table cellpadding="3" cellspacing="1">
  <tr>
    <th>
      订单来源</th>
    <th>系统订单号</th>
    <th>收货人</th>
    <th>总金额</th>
    <th>产品</th>
    <th>手机</th>
	<th>地址</th>
	<th>订单时间</th>
	<th>快递公司</th>
	<th>单号</th>
	<th>跟进状态</th>
    <th>操作</th>
  <tr>
  <?php 
    $i=0;
	if(count($order_list)>0){
	foreach($order_list AS $index => $array_val){
		$i++;
  ?>
   <tr>
    <td><?php echo $array_val['from_where']?></td>
    <td><?php echo $array_val['sys_order_sn']?></td>
    <td><?php echo $array_val['user']?></td>
    <td><?php echo $array_val['money']?></td>
    <td><?php echo $array_val['product_name']?></td>
    <td><?php echo $array_val['mobile']?></td>
	<td><span id="order_<?php echo $i;?>"><?php echo sub_str($array_val['address'],10);?></span><div id="address_<?php echo $i;?>" style="height:20px;margin-top:-1px;position:absolute;color:#fff;background-color:red;display:none"><?php echo $array_val['address'];?></div></td>
	<td><?php echo substr($array_val['order_time'],4,10);?></td>
	<td><?php echo $array_val['express_com']?></td>
	<td><?php echo $array_val['danhao']?></td>
	<td><?php if($array_val['status']==0){echo '未跟进';}else if($array_val['status']==1){echo '跟进中';}else if($array_val['status']==2){ echo '已完结';}?></td>
    <td><a href="tracing.php?sn=<?php echo  $array_val['order_id'];?>">跟进</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="trace_record.php?sn=<?php echo  $array_val['order_id'];?>">跟进详情</a></td>
  <tr>
  <?php 
      } 
	}
  ?>
  </table>
 
<!-- 分页 -->
  </div>
 
</form>
<script type="text/javascript">
var num = <?php echo count($order_list);?>;
for (i=1;i<=num;i++){
    hide_show(i);
}
function hide_show(i){
	//alert(22);
	$("#order_"+i).hover(function() {         
        $("#address_"+i).show();  
    },function(){
           $("#address_"+i).fadeOut(1000);  
        }

   ); 
}

function err_hide(){
	 $("#error").css("display","none"); 
}
</script>
</body>
</html>